import LanguageData from '@/assets/langconfig.js'

const app = {
  state: {
    userType: 0, // 0未登录，1已登录 2，有插件未登录
    language: null,
    openLoading: false,
    slideName: 'right', // 过度动画
    indexInfo: null,
    headerInfo: null,
    invitation: null,
    miningInfo: null,
    autoBetInfo: null,
    userInfo: {},
    userCode: null // 用户code
  },
  mutations: {
    setUserType(state, data) { // 设置状态
      if (data) {
        state.userType = data
      }
    },
    setUserCode(state, data) { // 用户code
      if (data) {
        state.userCode = data
      }
    },
    app_setSlideName(state, slide) {
      if (slide) { // 如果时间戳存在
        state.slideName = slide
      } else {
        state.slideName = 'right'
      }
    },
    app_openLoading(state) {
      state.openLoading = true
    },
    app_closeLoading(state) {
      state.openLoading = false
    },
    handleChangelang(state, language) {
      if (language) {
        state.language = language
      } else {
        state.language = {
          lang: 'Chinese',
          name: '中文',
          picture: 'https://www.artup.com/img/mp4/china.png'
        }
      }
      state.headerInfo = null
      state.indexInfo = null
      state.invitation = null
      state.miningInfo = null
      state.autoBetInfo = null
      state.headerInfo = LanguageData[state.language.lang].headerInfo
      state.indexInfo = LanguageData[state.language.lang].indexInfo
      state.invitation = LanguageData[state.language.lang].invitation
      state.miningInfo = LanguageData[state.language.lang].miningInfo
      state.autoBetInfo = LanguageData[state.language.lang].autoBetInfo
    },
    assignmentUserinfo(state, data) {
      if (data) {
        state.userInfo = data
      }
    }
  },
  actions: {}
}
export default app
